Claim 6 Count the total number of neuron fragments individually labeled in the volume


In [1]:
import numpy as np
import ndio.remote.neurodata as nd
from datetime import datetime

startTime = datetime.now()

oo = nd()

token = 'kasthuri2015_ramon_v1'
channel = 'neurons'
res = 3
pixel_dim = 0.024*0.024*0.030  #can get from LIMS

In [2]:
import ndio.ramon as ramon

# Don't count all objects, because RAMONNeuron paint is already counted in RAMONSegments

# Segments in cylinder
segment_ids_cyl = oo.get_ramon_ids(token, channel, ramon_type=ramon.RAMONSegment)

# Segments in volume are not RAMONified, so doing the hard way 
# TODO - RAMONIFY

token = 'kat11segments'
channel = 'annotation'
res = 3
image_size = oo.get_token_info(token)['dataset']['imagesize'][str(res)]

unique_count = []

for i in range(1, image_size[2]+1, 16): #TODO hardcoded z
    print str(i).zfill(4),    
    z_start = i
    z_stop = np.min([image_size[2]+1, i + 16])
    im = oo.get_volume(token, channel, 0, image_size[0], 0, image_size[1], z_start, z_stop, resolution=res)
    unique_count = np.concatenate([np.ravel(unique_count),np.ravel(np.unique(im.cutout))])

    segment_ids_all = np.shape(np.unique(unique_count))[0] - 1  #remove 0 label

print datetime.now() - startTime


0001 0017 0033 0049 0065 0081 0097 0113 0129 0145 0161 0177 0193 0209 0225 0241 0257 0273 0289 0305 0321 0337 0353 0369 0385 0401 0417 0433 0449 0465 0481 0497 0513 0529 0545 0561 0577 0593 0609 0625 0641 0657 0673 0689 0705 0721 0737 0753 0769 0785 0801 0817 0833 0849 0865 0881 0897 0913 0929 0945 0961 0977 0993 1009 1025 1041 1057 1073 1089 1105 1121 1137 1153 1169 1185 1201 1217 1233 1249 1265 1281 1297 1313 1329 1345 1361 1377 1393 1409 1425 1441 1457 1473 1489 1505 1521 1537 1553 1569 1585 1601 1617 1633 1649 1665 1681 1697 1713 1729 1745 1761 1777 1793 1809 1825 1841 0:25:50.096649

In [3]:
print 'Segments in cylinder: ' + str(np.shape(segment_ids_cyl)[0]) + ' Total segments: ' + str(segment_ids_all)


Segments in cylinder: 3945 Total segments: 6655